package org.zxp.javacheck.javatypeget;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @program: effectiveJava
 * @description:
 * @author: X-Pacific zhang
 * @create: 2019-09-04 17:34
 **/
public class Test {
    public static void main(String[] args){
        //定义时写明了类型的可以取名称，前提是拿到interface的类类型
        Type[] types = GenericSubClass1.class.getGenericInterfaces();
        ParameterizedType parameterized = (ParameterizedType) types[0];
        System.out.println(parameterized.getActualTypeArguments()[0].getTypeName());
        System.out.println(parameterized.getActualTypeArguments()[1].getTypeName());
        System.out.println(parameterized.getActualTypeArguments()[2].getTypeName());



        //定义时没有写明了类型的取出A,B,C，前提是拿到interface的类类型
//        Type[] types = GenericSubClass2.class.getGenericInterfaces();
//        ParameterizedType parameterized = (ParameterizedType) types[0];
//        System.out.println(parameterized.getActualTypeArguments()[0].getTypeName());
//        System.out.println(parameterized.getActualTypeArguments()[1].getTypeName());
//        System.out.println(parameterized.getActualTypeArguments()[2].getTypeName());
    }

    @org.junit.Test
    public void testMname(){
        System.out.println("com.sinosoft.esdemo.domain".replaceAll("\\.", "/"));


        String[] entityPaths = {"a","b"};

        Stream.of(Arrays.asList(entityPaths)).flatMap(list -> list.stream()).forEach(s -> System.out.println(s));
    }
}
